home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / t3dlib / source / tddd2ps.c < prev    next >
C/C++ Source or Header  |  1995-02-13  |  2KB  |  67 lines

  1. /* tddd2ps.c - convert TTDDD file to PostScript viewing format
  2.  *           - written by Glenn M. Lewis - 7/22/91
  3.  */
  4.  
  5. static char rcs_id[] = "$Id: tddd2ps.c,v 1.6 1993/02/14 17:44:16 glewis Exp $";
  6.  
  7. #include <stdio.h>
  8. #include "t3dlib.h"
  9. #ifdef __STDC__
  10. #include <stdlib.h>
  11. #include <strings.h>
  12. #include "tddd2ps_protos.h"
  13. #endif
  14.  
  15. main(argc, argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     char filename[256], rootname[256], *c1, *c2;
  20.     int i, view;
  21.     WORLD *world;
  22.     FILE *inp, *out;
  23.  
  24.     view = VIEW_ALL_FOUR;
  25.     rootname[0] = filename[0] = '\0';
  26. /*    strcpy(rootname, "model");    ** The default for reading stdin */
  27.     for (i=1; i<argc; i++) {
  28.         if (argv[i][0] == '-') {
  29.             switch(argv[i][1]) {
  30.                 case 'a': view=VIEW_ALL_FOUR; break;
  31.                 case 't': view=VIEW_TOP; break;
  32.                 case 'f': view=VIEW_FRONT; break;
  33.                 case 'r': view=VIEW_RIGHT; break;
  34.                 case 'i': view=VIEW_ISO; break;
  35.                 case 'h':
  36.                 default:
  37.                     fprintf(stderr, "Usage: %s [-all|-top|-front|-right|-iso] [infile] [outfile]\n", argv[0]);
  38.                     exit(-1);
  39.             }
  40.         } else if (filename[0]) {
  41.             strcpy(rootname, argv[i]);
  42.         } else {
  43.             strcpy(filename, argv[i]);    /* Make root of filename the default */
  44.             for (c1=rootname,c2=argv[i]; (*c1 = *c2++) && *c1!='.'; c1++) ;
  45.             *c1 = '\0';
  46.             strcat(rootname, ".ps");
  47.         }
  48.     }
  49.  
  50.     if (!filename[0]) inp = stdin;
  51.     else if (!(inp = fopen(filename, "r"))) {
  52.         fprintf(stderr, "Can't open '%s' for input.\n", filename);
  53.         exit(-1);
  54.     }
  55.     if (!rootname[0]) out = stdout;
  56.     else if (!(out = fopen(rootname, "w"))) {
  57.         fprintf(stderr, "Can't open '%s' for output.\n", rootname);
  58.         exit(-1);
  59.     }
  60.  
  61.     world = read_World(inp);
  62.     write_PostScript(world, out, view);
  63.     free_World(world);
  64.     exit(0);
  65. }
  66.  
  67.